package A_review.review9_4;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

public class Class77 {

      List<List<Integer>>  result= new ArrayList<>();
       LinkedList<Integer>  path= new LinkedList<>();

       int find(int n,int k){
           int count=0;

backing(1,n,k);
           return  count;
       }


    void  backing(int start,int n,int k){
           if (path.size()>k){
               return;
           }
           if (path.size()==k){
               result.add(new ArrayList<>(path));
           }
        for (int i = start; i <=n ; i++) {
            path.add(i);
            backing(i+1,n,k);
            path.remove(path.size()-1);

        }

    }

    public static void main(String[] args) {

        Class77 class77 = new Class77();
        class77.find(4,2);

        for ( List list: class77.result) {
            Iterator iterator = list.iterator();
            while (iterator.hasNext()){
                System.out.print(iterator.next()+" ");
            }
            System.out.println();
        }

    }



}
